

import vbutton from '../components/vbutton'

export default {
  name: 'loginindex',
  data() {
    return {
      logintopic:"FOODSYSTEM",
      loginusername:"User name",
      loginpassward:"Passward",
      loginHint:"please enter your uesr name and passward.",
      loginbtn:"login",
      resbtn:"register",
      loginstr:"Remember",
      loginmes:{
        username:'admin',
        userpas:'123456'
      }
    }
  },
  components:{
    vbutton
  },
  methods:{
    gotologin:function () {
      //this.$router.push({path:'mysystem'});
      //console.log("gogogo");
      var loginname=this.loginmes.username;
      var loginpas=this.loginmes.userpas;
      let self=this;
      //self.$router.push("/mysystem");
      this.$http.post(
        "/api/login",
        {
          username:loginname,
        })
        .then(function (res) {
          //console.log(res.data.data[0].userpas);
          console.log("请求成功")
          if(loginpas === res.data.data[0].userpas){
            alert("登录成功");
            self.$router.push("/mysystem");
            console.log(res);
          }else {
            alert("登录失败");
          }
          //console.log(res);
        })
        .catch(function (err) {
          console.log(err);
          alert("服务器错误")
        });
    },
    gotores:function(){
      this.$router.replace({path:'/resindex'})
      console.log(123);
    }
  }
}
